package demo10_flyweight.model;

import demo10_flyweight.util.Md5Util;

public abstract class Material {

    private String content;

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void display(Attributes attributes) {
        System.out.println("当前文件：" + getContent() + ",位置：" + attributes.getLocaltion() + ",大小：" + attributes.getSize());
    }


    @Override
    public boolean equals(Object obj) {
        /**
         * 模拟相同内容文件相同
         */
        Material material = (Material) obj;
        return Md5Util.getFileMd5(this).equals(Md5Util.getFileMd5(material));
    }
}
